package com.library.entity;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user")
public class User implements java.io.Serializable {

	// Fields

	private Integer id;
	private String username;
	private String password;
	private Integer gender;
	private Timestamp createTime;
	private Set<UserVoteBook> userVoteBooks = new HashSet<UserVoteBook>(0);
	private Set<Book> books = new HashSet<Book>(0);

	//常量
	public static final Integer USER_GENDER_MALE = 0;//男
	public static final Integer USER_GENDER_FEMALE = 1;//女

	// Constructors

	/** default constructor */
	public User() {
	}

	/** minimal constructor */
	public User(String username, String password) {
		this.username = username;
		this.password = password;
	}

	/** full constructor */
	public User(String username, String password, Integer gender,
			Timestamp createTime, Set<UserVoteBook> userVoteBooks,
			Set<Book> books) {
		this.username = username;
		this.password = password;
		this.gender = gender;
		this.createTime = createTime;
		this.userVoteBooks = userVoteBooks;
		this.books = books;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "username", nullable = false, length = 20)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", nullable = false, length = 20)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "gender")
	public Integer getGender() {
		return this.gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	@Column(name = "create_time", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<UserVoteBook> getUserVoteBooks() {
		return this.userVoteBooks;
	}

	public void setUserVoteBooks(Set<UserVoteBook> userVoteBooks) {
		this.userVoteBooks = userVoteBooks;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Book> getBooks() {
		return this.books;
	}

	public void setBooks(Set<Book> books) {
		this.books = books;
	}

}